/*
    打地鼠
*/
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main() {
    srand(time(0));
    int map[3][3] = {};
    int row = 0,col = 0, time = 0,curr = 0, i = 0, j = 0, missed = 0;
    int hamx = 0, hamy = 0, num = 0;
    printf("请输入要打的次数：");
    scanf ("%d", &time);
        for (row = 0; row <= 2; row++) {
   	    for (col = 0; col <= 2; col++){
	    printf("%c",map[row][col] = '*');
 	    }
        printf("\n");
    	} 
    do {
    	i = rand() % 3;
    	j = rand() % 3;
        printf("请输入锤子所在的位置：");
        scanf("%d%d",&hamx,&hamy);
   	map[i][j] = 'X';
	map[hamx - 1][hamy -1] = 'O';
        for (row = 0; row <= 2; row++) {
   	    for (col = 0; col <= 2; col++){
	    printf("%c",map[row][col] );
 	    }
        printf("\n");
    	} 
	map[hamx - 1][hamy - 1] = '*';
   	map[i][j] = '*';
    	if ((hamx - 1 != i) || (hamy - 1 != j)) {
            printf("呜！！！地鼠跑啦\n");
  	    missed++;
	}
	else  {
  	    num++;
 	    printf("恭喜啦，打中了耶！！！\n");
 	}
	    printf("打中%d次，没打中%d次\n",num,missed);
	curr++;
    } while (curr < time) ;
    printf("很遗憾，游戏失败\n");
    return 0;
}
